<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head "南航明珠商城-<#if isupdate>编辑<#else>发布</#if>活动">
</@frame.head>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理中心 <span class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span> <#if isedit>编辑<#else>发布</#if>活动 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
<form method="post" name="save_form"  id="save_form"  action="${contextPath}/activity/<#if isupdate>update_activity<#else>save_activity</#if>"  >    
   <input type="hidden" name="id" id="productSaleActiveid" value="${(productSaleActive.id?c)!}"  />                        
   <input type="hidden" id="saleProducIds" name="productIds" value="${productSaleActive.proIds}"/>
   <input type="hidden" id="saleProductLength" value='${productSaleActive.proIds?split(",")?size-1}' />
    <div class="text-c">
    <table class="table">
      <tr style="<#if fromType =='2'>display: none;</#if>"> <!-- fromType =='2'表示“添加限时统一折扣活动”功能调用此页面  -->
        <td>活动类型：</td>
        <td>
           <span class="select-box radius">
           <select class="select"  name="activeType" onchange="change();" id="activityType" <#if isupdate>disabled="disabled"</#if>>
           <option value="1" >统一限时折扣</option>
           <option value="2"<#if  productSaleActive.activeType == 2>selected="selected"</#if>>特惠</option>
           </select>
           </span>
        </td>
        <td><font color="red">*</font>  请选择活动类型</td>
      </tr>
      <tr>
        <td>活动名称：</td>
        <td><input type="text" class="input-text radius"  placeholder="请输入活动名称" value="${productSaleActive.name}" id="name" name="name"/></td>
        <td><font color="red">*</font>  请输入200字以内的活动名称</td>
      </tr>
      <tr>
        <td>开始时间：</td>
        <td>
        <input  type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'%y-%M-%d',maxDate:'#F{$dp.$D(\'endDate\')}',readOnly: true })" id="startDate" 
               value='${(productSaleActive.startDate?string("yyyy-MM-dd HH:mm:ss"))!}' name="startDate"  class="input-text Wdate">
         </td>
        <td><font color="red">*</font></td>
      </tr>
      <tr>
        <td>结束时间：</td>
        <td>
          <input  type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'startDate\')||\'%y-%M-%d\'}',readOnly: true })" id="endDate" 
               value='${(productSaleActive.endDate?string("yyyy-MM-dd HH:mm:ss"))!}' name="endDate"    class="input-text Wdate">
        </td>
        <td><font color="red">*</font></td>
      </tr>
      <tr>
      <tr>
        <td>折扣：</td>
        <td><input type="text" name="sale" id="sale" class="input-text radius"  placeholder="请输入折扣" value='${(productSaleActive.sale?string("0.##"))!}' onkeyup="value=value.replace(/[^\d.]/g,'')"/></td>
        <td><font color="red">*</font>  只允许输入大于0小于1的小数,小数位数只允许到小数后两位</td>
      </tr>
      <tr>
        <td>选择商品：</td>
        <td><button type="button" class="btn btn-primary radius" onclick="toAddProduct();">点击选择商品</button>&nbsp;&nbsp;&nbsp;<font color="red">*</font></td>
        <td></td>
      </tr>
      <tr>
         <td></td>
            <td colspan="2">
             <div id="product_id">您已选择${productSaleActive.proIds?split(",")?size-1}款商品</div>
             <div  class="text-c">
               <table id="productTable"  class="table table-border table-bordered table-bg">
                     <thead> 
                     <tr>
                        <th >商品编号</th>
                        <th >商品名称</th>
                        <th >商品分类</th>
                        <th >供应商</th>
                        <th >商品品牌</th>
                        <th >库存</th> 
						<#if productSaleActive.activeType == 2>
						<th>商品原价</th>
						<#else>
						<th class="tehui" style="display:none;">商品原价</th>
						</#if> 
                        <th >商品价格</th>
                        <th >操作</th>
                     </tr>
                     </thead>
                     <tbody id="productTbody">
                     <#if proList??>
                       <#list proList as product>
                          <tr id="sale${product.id}">
                             <td>${product.id}</td>
                             <td>${product.baseInfo.name}</td>
                             <td>
                             <#if product.productProperty??>
                                <#if product.productProperty.prodTypeFour??>
						     	 	${product.productProperty.prodTypeFour.name}
                                <#elseif product.productProperty.prodTypeThree??>
						     	 	${product.productProperty.prodTypeThree.name}
                                <#elseif product.productProperty.prodTypeTwo??>
						     	 	${product.productProperty.prodTypeTwo.name}
                                <#elseif product.productProperty.prodTypeOne??>
						     	 	${product.productProperty.prodTypeOne.name}
                                </#if>
                             </#if>
                             </td>
                             <td>${product.merchant.mercName}</td>
                             <td>${brandMap['${product.brandId}']}</td>
                             <td>${product.storeInfo.storeNum}</td>
                             <td>${product.priceInfo.payOneMileage}公里</td>
							 <td  class="tehui" <#if productSaleActive.activeType != 2>style="display:none;"</#if>>
							 <input type="text"  class="input-text radius text-c money" style="width:70px;" value="${product.priceInfo.payCostMileage}" />
							 </td>
                             <td><a href="javascript:void(0);"  class="del-c" id="${product.id}">删除</a>
                             </td>
                          </tr>
                       </#list>
                     </#if>
                     </tbody>
               </table>
               </div>
           </td>
      </tr>
      <tr class="xianshi" <#if productSaleActive.activeType == 2>style="display:none;"</#if> >
        <td>活动简介：</td>
        <td><textarea class="textarea" placeholder="请输入活动简介" id="dec" name="dec" maxlength="250">${productSaleActive.dec}</textarea></td>
        <td><font color="red">*</font>  请输入250字以内的活动简介</td>
      </tr>
      <tr>
        <td colspan="2" style="text-align:center;">
        <button type="button" class="btn btn-success radius" onclick="sub_form();">提交</button>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-secondary radius" onclick="cancle();">取消</button>
        </td>      
        <td></td>  
      </tr>
    </table>
    </div>
</form>
    
</div>
<@frame.end "default">
</@frame.end>
</html>
<script type="text/javascript" src="${contextPath}/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/laypage/laypage.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/activity/activity_add_or_update.js"></script>
<script type="text/javascript">
var path="${contextPath}";
</script>